﻿
Partial Class AdminNewTaxistInfo
    Inherits Page

    Public TaxistId As Guid
    Public Taxist As taxist
    Public ReturnUrl As String
    Public Action As String

    Protected Overrides Sub OnLoad(e As EventArgs)
        MyBase.OnLoad(e)

        returnUrl = Request.QueryString("returlurl")
        taxistId = Guid.Parse(Request.QueryString("taxistid").ToString()) '4e5ddb9c-7dd6-41ee-b9f0-37997978bada
        action = Request.QueryString("action")



        Using context As New TaxiEntities()
            If action = "remove" Then
                Dim toRemove = context.taxist.FirstOrDefault(Function(a) a.taxi_id = taxistId)
                If IsNothing(toRemove) <> True Then
                    context.taxist.Remove(toRemove)
                    context.SaveChanges()

                    Response.Redirect("/adminnew/taxists.aspx")
                End If
            Else
                taxist = context.taxist.Include("transfers").Include("cities").Include("rating").Include("torders").Include("torders.orders").FirstOrDefault(Function(a) a.taxi_id = taxistId)
            End If
        End Using
    End Sub

End Class
